﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using VCN.App.DataTransferObjects;
using VCN.App.DataAccessLayer;

namespace VCN.home.UC
{
    public partial class NewsUC : System.Web.UI.UserControl
    {
        string _str_title;


        #region Properties
        public string Str_title
        {
            get { return _str_title; }
            set { _str_title = value; }
        }
        #endregion
        public Boolean m_b_CoTinLienQuan;
        int m_int_Id;
        NewsDAO m_newDao = new NewsDAO();
        protected void Page_Load(object sender, EventArgs e)
        {
            BindData();
        }
        //get id of news
        public void BindData()
        {
            DataTable v_dtb = new DataTable();             
            if (Request.QueryString["NId"] != null)
            {
                m_int_Id = int.Parse(Request.QueryString["NId"].ToString());
                VCN.App.DataTransferObjects.News v_news = m_newDao.SelectById(m_int_Id);
                if (v_news != null)
                {
                    v_news.ViewCount++;
                    m_newDao.update(v_news);
                }
                v_dtb = m_newDao.selectTopNews(m_int_Id);                
                if (v_dtb != null && v_dtb.Rows.Count > 0)
                {
                    m_b_CoTinLienQuan = true;
                }
                else
                    m_b_CoTinLienQuan = false;
            }
            else
                m_b_CoTinLienQuan = false;                        
            rpt_other_new.DataSource = v_dtb;
            rpt_other_new.DataBind();
        }
    }
}